package Test05;
//键盘输入字符串，打乱里面的内容

import java.util.Random;
import java.util.Scanner;

public class test25 {
    public static void main(String[] args) {
        //1、键盘录入一个字符串
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个字符串：");
        String str = sc.next();

        //2、将字符串放入字符数组
        char[] arr = str.toCharArray();
        Random r = new Random();

        //3、打乱数据
        for (int i = 0; i < arr.length; i++) {
            int index = r.nextInt(arr.length - 1);
            char temp = arr[i];
            arr[i] = arr[index];
            arr[index] = temp;
        }

        //4、将字符数转换为字符串
        String newStr = new String(arr);

        //5、打印
        System.out.println(newStr);

    }
}
